<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('额度变更日志列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId" th:object="${hzMerBalanceLog}">
                <div class="select-list">
                    <ul>
                        <li hidden="hidden">
                            <input type="text" name="balanceId" th:value="*{balanceId}"/>
                        </li>
                        <li>
                            <label class="col-sm-3 control-label" style="line-height: 25px;width:30%">变更类型：</label>
                            <div class="col-sm-9" style="line-height: 25px;width:18%">
                                <select id="dealType" name="dealType" class="form-control">
                                    <option value="">全部</option>
                                    <option value="1">人工入账</option>
                                    <option value="2">交易出账</option>
                                    <option value="3">交易失败退款入账</option>
                                    <option value="4">自动入账</option>
                                </select>
                            </div>
                        </li>
                        <li class="select-time">
                            <label>添加时间： </label>
                            <input type="text" class="time-input" id="startTime" placeholder="开始时间"
                                   name="startTime"/><span>-</span><input type="text"
                                                                          class="time-input"
                                                                          id="endTime"
                                                                          placeholder="结束时间"
                                                                          name="endTime"/>
                        </li>
                        <!--                        <li>-->
                        <!--                            添加时间：<input type="text" name="addTime"/>-->
                        <!--                        </li>-->
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <!--            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="platform:zbMerBalanceLog:add">-->
            <!--                <i class="fa fa-plus"></i> 添加-->
            <!--            </a>-->
            <!--            <a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()"-->
            <!--               shiro:hasPermission="platform:zbMerBalanceLog:edit">-->
            <!--                <i class="fa fa-edit"></i> 修改-->
            <!--            </a>-->
            <!--            <a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()"-->
            <!--               shiro:hasPermission="platform:zbMerBalanceLog:remove">-->
            <!--                <i class="fa fa-remove"></i> 删除-->
            <!--            </a>-->
            <a class="btn btn-warning" onclick="$.table.exportExcel()">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('mng:balancelog:edit')}]];
        var removeFlag = [[${@permission.hasPermi('mng:balancelog:remove')}]];
        var prefix = ctx + "mng/balancelog";
    $(function () {
        var options = {
            url: prefix + "/list",
            modalName: "额度变更日志",
            exportUrl: prefix + "/export",
            showExport: true,
            columns: [
                {
                    field: 'logId',
                    title: 'log_id',
                    visible: false
                },
                {
                    field: 'dealType',
                    title: '变更类型',
                    // sortable: true
                    formatter: function (value, row, index) {
                        if (value == 1) {
                            return "人工入账";
                        } else if (value == 2) {
                            return "交易出账";
                        } else if (value == 3) {
                            return "交易失败退款入账";
                        } else if (value == 4) {
                            return "自动入账";
                        }
                    }
                },
                {
                    field: 'amount',
                    title: '变更金额(元)',
                    // sortable: true
                    formatter: function (value, row, index) {
                        return Money(value)
                    }
                },
                {
                    field: 'remark',
                    title: '变更说明',
                    sortable: true
                },
                {
                    field: 'updateTime',
                    title: '更新时间',
                    sortable: true
                }
            ]
        };
        $.table.init(options);
        $.table.search();
        // $(".fixed-table-toolbar").hide()
    });

    function Money(num) {
        if (!num) {
            return '0.00'
        }
        num = new BigNumber(num)
        num = num.div(100).toString()
        num = num.split(".");  // 分隔小数点
        var arr = num[0].split("").reverse();  // 转换成字符数组并且倒序排列
        var res = [];
        for (var i = 0, len = arr.length; i < len; i++) {
            if (i % 3 === 0 && i !== 0) {
                res.push(",");   // 添加分隔符
            }
            res.push(arr[i]);
        }
        res.reverse(); // 再次倒序成为正确的顺序
        if (num[1]) {  // 如果有小数的话添加小数部分
            res = res.join("").concat("." + num[1]);
        } else {
            res = res.join("").concat(".00");
        }
        return res;
    }


</script>
</body>
</html>